<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 根据输入的三个数字，判断是这一年的第几天
例如：

var year = 2016
var month = 2
var day = 11

// 逻辑代码

// 输出是第 42 天
输入月份，显示当月的天数。 -->
    <!-- 请输入年份<input class="year" type="text">
    请输入月份 <input class="month" type="text">
    请输入第几天 <input class="day" type="text">
    <button class="btn">查询第几天</button> -->
    <script>
        // var year = document.getElementsByClassName("year")[0];
        // var month = document.getElementsByClassName("month")[0];
        // var day = document.getElementsByClassName("day")[0];
        // var btn = document.getElementsByClassName("btn")[0];
        // btn.onclick = function () {
            var year = prompt("请输入年份")
            var month = prompt("请输入月份")
            var day = prompt("请输入日")
            var days = 0;
            switch (Number(month) - 1) {
                case 11:
                    days += 30
                case 10:
                    days += 31
                case 9:
                    days += 30
                case 8:
                    days += 31
                case 7:
                    days += 31
                case 6:
                    days += 30
                case 5:
                    days += 31
                case 4:
                    days += 30
                case 3:
                    days += 31
                case 2:
                    if (year % 4 == 0 || (year % 400 == 0 && year % 100 != 0)) {
                        days += 29
                    } else {
                        days += 28
                    }
                case 1:
                    days += 31
                    case 0:
                        days +=Number(day)
                        break;
                        default:
                            console.log("请正确输入")
                           
            }
            alert(days+"天")
           
        // }
    </script>
</body>

</html>